
package com.yfz.day01;

/**
 * 两数之和 II - 输入有序数组 167
 */
class Soluntion1 {
    public int[] twoSum(int[] numbers, int target) {
        int len = numbers.length;
        int []result =new int[2];
        int start = 0 ; int end = len -1 ;
        for(int i = 0 ;i<len ;i++)
        {
            if(numbers [start] + numbers [end] < target) start++;
            else if(numbers[start]+ numbers[end] > target) end --;
            else result= new int[]{start+1,end+1};
        }
        return result;
    }
}